package com.equipment;

import com.util.EncodingUtil;

/**
 * 发送读车辆信息指令 FDA6
 * @version 1.18
 * @author 刘亚东
 *
 */
public class ReadVehicleRequest {
	private String STX = "55AA"; // 帧开始标志
	private String RSCTL = "00"; // 串口帧序列号
	private String Length = ""; //长度
	private String code = "FD"; // 代码
	private String broadening = "A6"; // 扩展代码
	private String BCC = ""; // 异或校验值
	private String ObuContractVersion=""; //OBU合同版本号，0x00,0x10,0x11,0x12,0x16
	private String VehiInfoLen = ""; // 要读取的车辆信息的长度
	private String Random = ""; // 8字节的随机数
	private String Access=""; // 8字节的认证码，11版本此处填写服务器端返回认证码，12和16版本此处填写全0

	public String command(String version,String VLen, String RM,String access) {
		this.ObuContractVersion=version;
		VehiInfoLen = EncodingUtil.desToHex(Integer.parseInt(VLen), 2);
		Random = RM;
		Access=access;
		// -----------------------------------------------------------------------------
		Length=EncodingUtil.desToHex((broadening+ObuContractVersion+VehiInfoLen+Random+Access).length()/2, 4);
		// DATA由代码+扩展子代码+车辆信息长度+随机数按顺序拼接组成
		String DATA =RSCTL +Length+ code + broadening + ObuContractVersion +VehiInfoLen + Random+Access;
		// 异或校验从RSCTL到DATA所有字节的异或值
		BCC = EncodingUtil.yihuo(EncodingUtil.change( DATA));
		String retn = STX + DATA+BCC; // 拼接完整的请求
		return retn;

	}

	public String getSTX() {
		return STX;
	}

	public void setSTX(String sTX) {
		STX = sTX;
	}

	public String getRSCTL() {
		return RSCTL;
	}

	public void setRSCTL(String rSCTL) {
		RSCTL = rSCTL;
	}

	public String getLength() {
		return Length;
	}

	public void setLength(String length) {
		Length = length;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getBroadening() {
		return broadening;
	}

	public void setBroadening(String broadening) {
		this.broadening = broadening;
	}

	public String getBCC() {
		return BCC;
	}

	public void setBCC(String bCC) {
		BCC = bCC;
	}

	public String getVehiInfoLen() {
		return VehiInfoLen;
	}

	public void setVehiInfoLen(String vehiInfoLen) {
		VehiInfoLen = vehiInfoLen;
	}

	public String getRandom() {
		return Random;
	}

	public void setRandom(String random) {
		Random = random;
	}

	public String getObuContractVersion() {
		return ObuContractVersion;
	}

	public void setObuContractVersion(String obuContractVersion) {
		ObuContractVersion = obuContractVersion;
	}

	public String getAccess() {
		return Access;
	}

	public void setAccess(String access) {
		Access = access;
	}

}
